<?php
require 'Admin/Controller/Controller.php ';
require 'Admin/Model/CarbrandModel.php';
class CarbrandController extends Controller{
		function listcarbrand(){
			$model = new CarbrandModel();
			$data = $model->getCarbrandList();
			//转向用户列表页面
			include 'Admin/View/brand/carbrandlist.php';
		}

		function carbrandform(){
			//转向添加用户页面
			include 'Admin/View/brand/carbrandform.php';
		}

		function carbrandedit(){
			$id = $_GET['id'];
			$model = new CarbrandModel();
			$result = $model->getCarbrandByID($id);
			include 'Admin/View/brand/carbrandedit.php';
		}

		function carbrandupdate(){
			$id = $_GET['id'];
			$model = new CarbrandModel();
			$result = $model->Updatecarbrand($id);
			if($result){
				echo '修改成功'.'<a href="admin.php?c=carbrand&m=listcarbrand">如果没有跳转，请点这里跳转</a>';
				header("refresh:3;admin.php?c=carbrand&m=carbrandlist = admin.php?c=carbrand&m=carbrandlist"); 	
			}else{
				echo '失败';
			}
		}

		function delcarbrand(){
			$id = $_GET['id'];
			$model = new Carbrandmodel();
			$result = $model->Delcarbrand($id);
			if($result){
				echo '删除成功'.'<a href="admin.php?c=carbrand&m=listcarbrand">如果没有跳转，请点这里跳转</a>';
				header("refresh:3;admin.php?c=carbrand&m=carbrandlist = admin.php?c=carbrand&m=carbrandlist"); 
			}else{
				echo '删除失败';
			}
		}

		function addcarbrand(){
			//获取表单的数据
			//调用model中的addUser方法，添加到数据库中
			//var_dump($_POST);
			$data = $_POST;
			$model = new CarbrandModel();
			$result = $model->addCarbrand($data);
			//如果成功，输出，转到列表页面
			if($result){
				echo '添加成功'.'<a href="admin.php?c=carbrand&m=listcarbrand">如果没有跳转，请点这里跳转</a>';
				header("refresh:3;admin.php?c=carbrand&m=listcarbrand = admin.php?c=carbrand&m=carbrandlist"); 
			}else{
				echo '失败';
			}

		}
	}
 ?>